<template>
  <el-dialog
          :model-value="dialogSeriesReviewLogsVisible"
          :title="dialogSeriesReviewLogsTitle"
          :before-close="handleCancelSeriesReviewLogsDialog"
          width="50%"
  >
    <el-table :data="tableData.listData" v-loading="isloading" border width="100%" max-height="350px">
      <el-table-column label="审核意见" prop="comments" />
      <el-table-column label="审核人" prop="reviewer"/>
      <el-table-column label="审核状态">
        <template #default="{row}">
          <span v-if="row.state == 1">提交审核</span>
          <span v-else-if="row.state == 2">审核通过</span>
          <span v-else-if="row.state == 3">审核不通过</span>
        </template>
      </el-table-column>
      <el-table-column label="审核时间" width="150px">
        <template #default="{row}">
          {{row.ctime.replace('T', ' ').replace('Z','')}}
        </template>
      </el-table-column>
    </el-table>
    <el-row class="mt10">
      <el-col :span="24">
        <table-pagination
                :queryList="queryList"
                :total="tableData.total"
                @pagination="getDataList"
        />
      </el-col>
    </el-row>
  </el-dialog>
</template>

<script>
  import {ref, reactive} from 'vue'
  import {getReviewSeries} from "@/api/media/review";
  import TablePagination from "@/views/public/TablePagination";

  export default {
    name: "SeriesReviewLogs",
    components: {TablePagination},
    props: {
      dialogSeriesReviewLogsTitle: {
        type: String,
        default: ''
      },
      dialogSeriesReviewLogsVisible: {
        type: Boolean,
        default: false
      },
      dialogSeriesReviewLogsSeriesid: {
        type: Number,
        default: 0
      }
    },
    emits: ['handleCancelSeriesReviewLogsDialog'],
    setup(props, context) {
      const isloading = ref(false)
      const queryList = reactive({
        page: 1,
        pagesize: 25,
        seriesid: 0
      })
      const tableData = reactive({
        total: 0,
        listData: []
      })

      /** 获取子集审核列表 **/
      const getDataList = () => {
        isloading.value = true
        queryList.seriesid = props.dialogSeriesReviewLogsSeriesid
        getReviewSeries(queryList).then(response => {
          isloading.value = false
          const {total, list} = response.data
          tableData.total = total
          tableData.listData = list
        })
      }

      /** 关闭弹框 **/
      const handleCancelSeriesReviewLogsDialog = () => {
        context.emit('handleCancelSeriesReviewLogsDialog')
      }

      return {
        handleCancelSeriesReviewLogsDialog,
        isloading,
        queryList,
        tableData,
        getDataList
      }
    }
  }
</script>

<style scoped>

</style>
